<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery-3.6.0.js"></script>
  </head>
  <body>
    <button>单击</button>
    <button>双击</button>
    <select id="address">
      <option value="NJ">南京</option>
      <option value="BJ">北京</option>
      <option value="SH">上海</option>
    </select>

    <form action="reg.html" method="post">
      <input type="text" id="name" />
      <button>提交</button>
    </form>
  </body>
</html>
<script>
  $('button:eq(0)').click(function () {
    console.log('====单击==========')
  })

  $('button:eq(1)').dblclick(function () {
    console.log('====双击==========')
  })

  $('#address').change(function () {
    console.log('========住址:' + $(this).val())
  })

  $('#name').focus(function () {
    console.log('===输入框获得焦点==========')
  })

  $('#name').blur(function () {
    console.log('===输入框失去焦点==========')
  })

  //表单提交  button 没有写type 并且 form表单 默认类型 submit
  $('form').submit(function () {
    if ($('#name').val() == '') {
      alert('请输入姓名！')
      return false
    }
    return true
  })
</script>
